﻿/* 
┏━━━━━━━━━━━＼／━━━━━━━━━━━┓      
┃┏━━━━━━━━━━━━━━━━━━━━━━┓┃
     ------------------------------------------    
       Author           : TengSea   
       Created          : Mouth-Day-Year                              
       Last Modified By : TengSea                                 
       Last Modified On : Mouth-Day-Year                                                               
       Description      : 
     __________________________________________
     Copyright (c) TengSea. All rights reserved.
 ┃┗━━━━━━━━━━━━━━━━━━━━━━┛┃                            
 ┗━━━━━━━━━∪━━━━∪━━━━━━━━━┛
 */

using Hhmocon.Mes.Application.Common;
using Hhmocon.Mes.Application.Response;
using Hhmocon.Mes.Repository.Domain;
using Hhmocon.Mes.Repository.Repository;
using Hhmocon.Mes.Repository.Repository.Energy.Energy_Elecdistribution;
using Hhmocon.Mes.Repository.Response;
using NPOI.SS.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Hhmocon.Mes.Repository.Response.GetGridElecdistrbutionAmountResponse;

namespace Hhmocon.Mes.Application.Energy
{
    public class EnergyElecdistributionApp
    {
        private PikachuRepository _pikachuRepository;
        private IEnergyElecdistributionRepository _energyElecdistributionRepository;

        public EnergyElecdistributionApp(PikachuRepository pikachuRepository, IEnergyElecdistributionRepository energyConsumptionRepository)
        {
            _pikachuRepository = pikachuRepository;
            _energyElecdistributionRepository = energyConsumptionRepository;
        }

        public elec_distribution_meter Insert(elec_distribution_meter data)
        {
            //取ID
            data.elect_distribution_meter_id = CommonHelper.GetNextGUID();
            data.modified_time = DateTime.Now;
            data.create_time = DateTime.Now;
            if (_pikachuRepository.Insert(data))
            {
                return data;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 配电网的电量页面
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <returns></returns>
        public GetGridElecdistributionResponse GetGridElecdistribution(DateTime StartTime,DateTime EndTime,string id)
        {

            GetGridElecdistributionResponse getGridElecdistributionResponse = new();
            List<elec_distribution_meter> elec_Distribution_Meters;
            if (id == null) elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();
            else elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();

            foreach (elec_distribution_meter elec_Distribution_Meter in elec_Distribution_Meters)
            {
                /*购电量*/
                //有功量/无功量
                getGridElecdistributionResponse.grid_active_energy_Over_grid_reactive_energy += (elec_Distribution_Meter.grid_active_energy / elec_Distribution_Meter.grid_active_energy);

                //尖电量
                getGridElecdistributionResponse.grid_sharp_power += elec_Distribution_Meter.grid_sharp_power;
                //峰电量
                getGridElecdistributionResponse.grid_peak_power += elec_Distribution_Meter.grid_peak_power;
                //谷电量
                getGridElecdistributionResponse.grid_valley_power += elec_Distribution_Meter.grid_valley_power;
                //最大需量
                getGridElecdistributionResponse.grid_maximum_demand += elec_Distribution_Meter.grid_maximum_demand;

                /*发电量*/
                //尖电量
                getGridElecdistributionResponse.pho_sharp_power_generation += elec_Distribution_Meter.pho_sharp_power_generation;
                //峰电量
                getGridElecdistributionResponse.pho_peak_charge_powewr = elec_Distribution_Meter.grid_peak_power;
                //谷电量
                getGridElecdistributionResponse.pho_valley_power_generation += elec_Distribution_Meter.pho_valley_power_generation;
                //上网电量
                getGridElecdistributionResponse.pho_on_grid_power += elec_Distribution_Meter.pho_on_grid_power;
                //自发自用
                getGridElecdistributionResponse.pho_selfuse_power += elec_Distribution_Meter.pho_selfuse_power;

                /*充电量*/
                //尖电量
                getGridElecdistributionResponse.stor_sharp_charge_powewr += elec_Distribution_Meter.stor_sharp_charge_powewr;
                //峰电量
                getGridElecdistributionResponse.stor_peak_charge_powewr += elec_Distribution_Meter.stor_peak_charge_powewr;
                //谷电量
                getGridElecdistributionResponse.stor_valley_charge_powewr += elec_Distribution_Meter.stor_valley_charge_powewr;
          

                /*放电量*/
                 //尖电量
                getGridElecdistributionResponse.stor_sharp_discharge_powewr += elec_Distribution_Meter.stor_sharp_discharge_powewr;
                //峰电量
                getGridElecdistributionResponse.stor_peak_discharge_powewr += elec_Distribution_Meter.stor_peak_discharge_powewr;
                //谷电量
                getGridElecdistributionResponse.stor_valley_discharge_powewr += elec_Distribution_Meter.stor_valley_discharge_powewr;
                //最大需量
                getGridElecdistributionResponse.stor_maximum_demand += elec_Distribution_Meter.stor_maximum_demand;
            }

            return getGridElecdistributionResponse;
        }

        /// <summary>
        /// 配电网的总电量页面
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public GetGridElecdistrbutionAmountResponse GetGridElecdistributionAmount(DateTime StartTime, DateTime EndTime, string id)
        {

            GetGridElecdistrbutionAmountResponse getGridElecdistributionResponse = new();
            List<elec_distribution_meter> elec_Distribution_Meters ;
            if (id == null) elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();
            else elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();



            foreach (elec_distribution_meter elec_Distribution_Meter in elec_Distribution_Meters)
            {

                //总电量
                getGridElecdistributionResponse.energyConsume += elec_Distribution_Meter.grid_purchased_electricity + elec_Distribution_Meter.pho_power_generation_total + elec_Distribution_Meter.stor_discharge_powewr_total;

                //有功量/无功量
                getGridElecdistributionResponse.gactive_energy_Over_reactive_energy +=
                    (elec_Distribution_Meter.grid_active_energy / elec_Distribution_Meter.grid_active_energy);

                //尖电量
                getGridElecdistributionResponse.sharp_power += elec_Distribution_Meter.grid_sharp_power
                                                                        + elec_Distribution_Meter.pho_sharp_power_generation
                                                                        + elec_Distribution_Meter.stor_sharp_charge_powewr
                                                                        + elec_Distribution_Meter.stor_sharp_discharge_powewr;
                //峰电量
                getGridElecdistributionResponse.peak_power += elec_Distribution_Meter.grid_peak_power
                                                                    + elec_Distribution_Meter.stor_peak_charge_powewr
                                                                    + elec_Distribution_Meter.stor_peak_discharge_powewr
                                                                    + elec_Distribution_Meter.pho_peak_charge_powewr;
                //谷电量
                getGridElecdistributionResponse.valley_power += elec_Distribution_Meter.grid_valley_power
                                                                    + elec_Distribution_Meter.pho_valley_power_generation
                                                                    + elec_Distribution_Meter.stor_valley_charge_powewr
                                                                    + elec_Distribution_Meter.stor_valley_discharge_powewr;
                //最大需量
                getGridElecdistributionResponse.maximum_demand += elec_Distribution_Meter.grid_maximum_demand
                                                                    + elec_Distribution_Meter.stor_maximum_demand
                                                                    + elec_Distribution_Meter.stor_maximum_demand_dicharge;

            }

            return getGridElecdistributionResponse;
        }


        /// <summary>
        /// 配电网的总电量页面 当日总电量百分比
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public List<GetGridElecdistrbutionAmountBaifenbi> GetGridElecdistributionAmountNowDay(string id)
        {

            DateTime StartTime = DateTime.Now;
            DateTime EndTime = DateTime.Now;
            StartTime = new DateTime(StartTime.Year, StartTime.Month, StartTime.Day, 00, 00, 00);
            EndTime = DateTime.Now;//后面只截取了年月

            GetGridElecdistrbutionAmountResponse getGridElecdistributionResponse = new();
            List<elec_distribution_meter> elec_Distribution_Meters;
            if (id == null) elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();
            else elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();



            foreach (elec_distribution_meter elec_Distribution_Meter in elec_Distribution_Meters)
            {

                //总电量
                getGridElecdistributionResponse.energyConsume += elec_Distribution_Meter.grid_purchased_electricity + elec_Distribution_Meter.pho_power_generation_total + elec_Distribution_Meter.stor_discharge_powewr_total;

                //有功量/无功量
                getGridElecdistributionResponse.gactive_energy_Over_reactive_energy +=
                    (elec_Distribution_Meter.grid_active_energy / elec_Distribution_Meter.grid_active_energy);

                //尖电量
                getGridElecdistributionResponse.sharp_power += elec_Distribution_Meter.grid_sharp_power
                                                                        + elec_Distribution_Meter.pho_sharp_power_generation
                                                                        + elec_Distribution_Meter.stor_sharp_charge_powewr
                                                                        + elec_Distribution_Meter.stor_sharp_discharge_powewr;
                //峰电量
                getGridElecdistributionResponse.peak_power += elec_Distribution_Meter.grid_peak_power
                                                                    + elec_Distribution_Meter.stor_peak_charge_powewr
                                                                    + elec_Distribution_Meter.stor_peak_discharge_powewr
                                                                    + elec_Distribution_Meter.pho_peak_charge_powewr;
                //谷电量
                getGridElecdistributionResponse.valley_power += elec_Distribution_Meter.grid_valley_power
                                                                    + elec_Distribution_Meter.pho_valley_power_generation
                                                                    + elec_Distribution_Meter.stor_valley_charge_powewr
                                                                    + elec_Distribution_Meter.stor_valley_discharge_powewr;
                //最大需量
                getGridElecdistributionResponse.maximum_demand += elec_Distribution_Meter.grid_maximum_demand
                                                                    + elec_Distribution_Meter.stor_maximum_demand
                                                                    + elec_Distribution_Meter.stor_maximum_demand_dicharge;
            }

            List<GetGridElecdistrbutionAmountBaifenbi> res = new();
            GetGridElecdistrbutionAmountBaifenbi r = new();
            r.name = "有功量/无功量";
            r.value = getGridElecdistributionResponse.gactive_energy_Over_reactive_energy;
            res.Add(r);
            r = new();
            r.name = "尖电量";
            r.value = getGridElecdistributionResponse.sharp_power;
            res.Add(r);
            r = new();
            r.name = "峰电量";
            r.value = getGridElecdistributionResponse.peak_power;
            res.Add(r);
            r = new();
            r.name = "谷电量";
            r.value = getGridElecdistributionResponse.valley_power;
            res.Add(r);
            r = new();
            //r.name = "最大需量";
            //r.value = getGridElecdistributionResponse.maximum_demand;
            //res.Add(r);
            //r = new();
           // r.name = "总电量";
           // r.value = getGridElecdistributionResponse.energyConsume;
           // res.Add(r);

            return res;
        }



        /// <summary>
        /// 电 总 折线图
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public GridElecdistributionLineChartResponse GetGridElecdistributionAmountLineChart(DateTime StartTime, DateTime EndTime, string id)
        {
            GridElecdistributionLineChartResponse getGridElecdistributionResponses = new();
            List<elec_distribution_meter> elec_Distribution_Meters;
            if (id == null) elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();
            else elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution(StartTime, EndTime).Where(c => c.elect_distribution_meter_id == id).ToList();

            int yearGap = StartTime.Year - EndTime.Year;
            int mouthGap = StartTime.Month - EndTime.Month;
            int dayGap = StartTime.Day - EndTime.Day;

            List<string> gap = ComputeMouth.ComputeMonth(StartTime.Year,StartTime.Month,EndTime.Year,EndTime.Month);
            //遍历年-月
            foreach (string temp in gap)
            {
                string[] a = temp.Split("-");
                string year = a?[0];
                string mouth = a?[1];
                //遍历//累加同月的数据
                GetGridElecdistrbutionAmountResponse getGridElecdistributionResponse = new GetGridElecdistrbutionAmountResponse();

                //用来存放同年-月的数据
                List<elec_distribution_meter> elec_Distribution_Meters_a = elec_Distribution_Meters.Where(c=>c.consumption_date.Year == int.Parse(year) && c.consumption_date.Month == int.Parse(mouth)).ToList();

                foreach (elec_distribution_meter elec_Distribution_Meter in elec_Distribution_Meters_a)
                {
                    //总电量
                    getGridElecdistributionResponse.energyConsume += elec_Distribution_Meter.grid_purchased_electricity + elec_Distribution_Meter.pho_power_generation_total + elec_Distribution_Meter.stor_discharge_powewr_total;

                    //有功量/无功量
                    getGridElecdistributionResponse.gactive_energy_Over_reactive_energy +=
                        (elec_Distribution_Meter.grid_active_energy / elec_Distribution_Meter.grid_active_energy);

                    //尖电量
                    getGridElecdistributionResponse.sharp_power += elec_Distribution_Meter.grid_sharp_power
                                                                            + elec_Distribution_Meter.pho_sharp_power_generation
                                                                            + elec_Distribution_Meter.stor_sharp_charge_powewr
                                                                            + elec_Distribution_Meter.stor_sharp_discharge_powewr;
                    //峰电量
                    getGridElecdistributionResponse.peak_power += elec_Distribution_Meter.grid_peak_power
                                                                        + elec_Distribution_Meter.stor_peak_charge_powewr
                                                                        + elec_Distribution_Meter.stor_peak_discharge_powewr
                                                                        + elec_Distribution_Meter.pho_peak_charge_powewr;
                    //谷电量
                    getGridElecdistributionResponse.valley_power += elec_Distribution_Meter.grid_valley_power
                                                                        + elec_Distribution_Meter.pho_valley_power_generation
                                                                        + elec_Distribution_Meter.stor_valley_charge_powewr
                                                                        + elec_Distribution_Meter.stor_valley_discharge_powewr;
                    //最大需量
                    getGridElecdistributionResponse.maximum_demand += elec_Distribution_Meter.grid_maximum_demand
                                                                        + elec_Distribution_Meter.stor_maximum_demand
                                                                        + elec_Distribution_Meter.stor_maximum_demand_dicharge;

                }
                //存入数组
                getGridElecdistributionResponses.energyConsume.Add(getGridElecdistributionResponse.energyConsume);
                getGridElecdistributionResponses.gactive_energy_Over_reactive_energy.Add(getGridElecdistributionResponse.gactive_energy_Over_reactive_energy);
                getGridElecdistributionResponses.sharp_power.Add(getGridElecdistributionResponse.sharp_power);
                getGridElecdistributionResponses.peak_power.Add(getGridElecdistributionResponse.peak_power);
                getGridElecdistributionResponses.valley_power.Add(getGridElecdistributionResponse.valley_power);
                getGridElecdistributionResponses.maximum_demand.Add(getGridElecdistributionResponse.maximum_demand);
                getGridElecdistributionResponses.mouth.Add(temp);
            }

            return getGridElecdistributionResponses;
        }


        /// <summary>
        /// 电 总 滑板图   年-月
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public GridElecdistributionLineChartResponse GetGridElecdistributionAmountLineChart( string id)
        {
            

            GridElecdistributionLineChartResponse getGridElecdistributionResponses = new();
            List<elec_distribution_meter> elec_Distribution_Meters;

            if (id == null) elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution();
            else elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution().Where(c => c.elect_distribution_meter_id == id).ToList();
            DateTime StartTime = DateTime.Now;
            DateTime EndTime = DateTime.Now;

            foreach (elec_distribution_meter e in elec_Distribution_Meters) {
                //如果时间小于开始时间
                if (DateTime.Compare(e.consumption_date,StartTime)<0) {
                    StartTime = e.consumption_date;
                }
                //如果时间大于开始时间
                if (DateTime.Compare(e.consumption_date, EndTime)> 0){
                    EndTime = e.consumption_date;
                }
            
            }

            int yearGap = StartTime.Year - EndTime.Year;
            int mouthGap = StartTime.Month - EndTime.Month;
            int dayGap = StartTime.Day - EndTime.Day;

            List<string> gap = ComputeMouth.ComputeMonth(StartTime.Year, StartTime.Month, EndTime.Year, EndTime.Month);
            //遍历年-月
            foreach (string temp in gap)
            {
                string[] a = temp.Split("-");
                string year = a?[0];
                string mouth = a?[1];
                //遍历//累加同月的数据
                GetGridElecdistrbutionAmountResponse getGridElecdistributionResponse = new GetGridElecdistrbutionAmountResponse();

                //用来存放同年-月的数据
                List<elec_distribution_meter> elec_Distribution_Meters_a = elec_Distribution_Meters.Where(c => c.consumption_date.Year == int.Parse(year) && c.consumption_date.Month == int.Parse(mouth)).ToList();

                foreach (elec_distribution_meter elec_Distribution_Meter in elec_Distribution_Meters_a)
                {
                    //总电量
                    getGridElecdistributionResponse.energyConsume += elec_Distribution_Meter.grid_purchased_electricity + elec_Distribution_Meter.pho_power_generation_total + elec_Distribution_Meter.stor_discharge_powewr_total;

                    //有功量/无功量
                    getGridElecdistributionResponse.gactive_energy_Over_reactive_energy +=
                        (elec_Distribution_Meter.grid_active_energy / elec_Distribution_Meter.grid_active_energy);

                    //尖电量
                    getGridElecdistributionResponse.sharp_power += elec_Distribution_Meter.grid_sharp_power
                                                                            + elec_Distribution_Meter.pho_sharp_power_generation
                                                                            + elec_Distribution_Meter.stor_sharp_charge_powewr
                                                                            + elec_Distribution_Meter.stor_sharp_discharge_powewr;
                    //峰电量
                    getGridElecdistributionResponse.peak_power += elec_Distribution_Meter.grid_peak_power
                                                                        + elec_Distribution_Meter.stor_peak_charge_powewr
                                                                        + elec_Distribution_Meter.stor_peak_discharge_powewr
                                                                        + elec_Distribution_Meter.pho_peak_charge_powewr;
                    //谷电量
                    getGridElecdistributionResponse.valley_power += elec_Distribution_Meter.grid_valley_power
                                                                        + elec_Distribution_Meter.pho_valley_power_generation
                                                                        + elec_Distribution_Meter.stor_valley_charge_powewr
                                                                        + elec_Distribution_Meter.stor_valley_discharge_powewr;
                    //最大需量
                    getGridElecdistributionResponse.maximum_demand += elec_Distribution_Meter.grid_maximum_demand
                                                                        + elec_Distribution_Meter.stor_maximum_demand
                                                                        + elec_Distribution_Meter.stor_maximum_demand_dicharge;

                }
                //存入数组
                getGridElecdistributionResponses.energyConsume.Add(getGridElecdistributionResponse.energyConsume);
                getGridElecdistributionResponses.gactive_energy_Over_reactive_energy.Add(getGridElecdistributionResponse.gactive_energy_Over_reactive_energy);
                getGridElecdistributionResponses.sharp_power.Add(getGridElecdistributionResponse.sharp_power);
                getGridElecdistributionResponses.peak_power.Add(getGridElecdistributionResponse.peak_power);
                getGridElecdistributionResponses.valley_power.Add(getGridElecdistributionResponse.valley_power);
                getGridElecdistributionResponses.maximum_demand.Add(getGridElecdistributionResponse.maximum_demand);
                getGridElecdistributionResponses.mouth.Add(temp);
            }

            return getGridElecdistributionResponses;
        }


        /// <summary>
        /// 电 总 滑板图  年
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public GridElecdistributionLineChartResponse GetGridElecdistributionAmountLineChartYear(string id)
        {


            GridElecdistributionLineChartResponse getGridElecdistributionResponses = new();
            List<elec_distribution_meter> elec_Distribution_Meters;

            if (id == null) elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution();
            else elec_Distribution_Meters = _energyElecdistributionRepository.GetGridElecdistribution().Where(c => c.elect_distribution_meter_id == id).ToList();
            DateTime StartTime = DateTime.Now;
            DateTime EndTime = DateTime.Now;

            foreach (elec_distribution_meter e in elec_Distribution_Meters)
            {
                //如果时间小于开始时间
                if (DateTime.Compare(e.consumption_date, StartTime) < 0)
                {
                    StartTime = e.consumption_date;
                }
                //如果时间大于开始时间
                if (DateTime.Compare(e.consumption_date, EndTime) > 0)
                {
                    EndTime = e.consumption_date;
                }

            }

            int yearGap = StartTime.Year - EndTime.Year;

            //遍历年
            for (int temp=0;temp<=yearGap; temp++)
            {
                
                //遍历//累加同年的数据
                GetGridElecdistrbutionAmountResponse getGridElecdistributionResponse = new GetGridElecdistrbutionAmountResponse();

                //用来存放同年的数据
                List<elec_distribution_meter> elec_Distribution_Meters_a = elec_Distribution_Meters.Where(c => c.consumption_date.Year == yearGap).ToList();

                foreach (elec_distribution_meter elec_Distribution_Meter in elec_Distribution_Meters_a)
                {
                    //总电量
                    getGridElecdistributionResponse.energyConsume += elec_Distribution_Meter.grid_purchased_electricity + elec_Distribution_Meter.pho_power_generation_total + elec_Distribution_Meter.stor_discharge_powewr_total;

                    //有功量/无功量
                    getGridElecdistributionResponse.gactive_energy_Over_reactive_energy +=
                        (elec_Distribution_Meter.grid_active_energy / elec_Distribution_Meter.grid_active_energy);

                    //尖电量
                    getGridElecdistributionResponse.sharp_power += elec_Distribution_Meter.grid_sharp_power
                                                                            + elec_Distribution_Meter.pho_sharp_power_generation
                                                                            + elec_Distribution_Meter.stor_sharp_charge_powewr
                                                                            + elec_Distribution_Meter.stor_sharp_discharge_powewr;
                    //峰电量
                    getGridElecdistributionResponse.peak_power += elec_Distribution_Meter.grid_peak_power
                                                                        + elec_Distribution_Meter.stor_peak_charge_powewr
                                                                        + elec_Distribution_Meter.stor_peak_discharge_powewr
                                                                        + elec_Distribution_Meter.pho_peak_charge_powewr;
                    //谷电量
                    getGridElecdistributionResponse.valley_power += elec_Distribution_Meter.grid_valley_power
                                                                        + elec_Distribution_Meter.pho_valley_power_generation
                                                                        + elec_Distribution_Meter.stor_valley_charge_powewr
                                                                        + elec_Distribution_Meter.stor_valley_discharge_powewr;
                    //最大需量
                    getGridElecdistributionResponse.maximum_demand += elec_Distribution_Meter.grid_maximum_demand
                                                                        + elec_Distribution_Meter.stor_maximum_demand
                                                                        + elec_Distribution_Meter.stor_maximum_demand_dicharge;

                }
                //存入数组
                getGridElecdistributionResponses.energyConsume.Add(getGridElecdistributionResponse.energyConsume);
                getGridElecdistributionResponses.gactive_energy_Over_reactive_energy.Add(getGridElecdistributionResponse.gactive_energy_Over_reactive_energy);
                getGridElecdistributionResponses.sharp_power.Add(getGridElecdistributionResponse.sharp_power);
                getGridElecdistributionResponses.peak_power.Add(getGridElecdistributionResponse.peak_power);
                getGridElecdistributionResponses.valley_power.Add(getGridElecdistributionResponse.valley_power);
                getGridElecdistributionResponses.maximum_demand.Add(getGridElecdistributionResponse.maximum_demand);
                getGridElecdistributionResponses.years.Add(temp.ToString());
            }

            return getGridElecdistributionResponses;
        }
    }
}
